package com.br.sae.controls;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.br.sae.model.dao.ProfessorBD;
import com.br.sae.model.entitys.Professor;

public class LogicaFormProfessores implements Logica {

	@Override
	public String executa(HttpServletRequest req, HttpServletResponse res)
			throws Exception {
		List<Professor> professores = consultaProfessor();
		req.setAttribute("professores", professores);
		System.out.println("Professores: " + professores.size());

		return "mostra_professor.jsp";
	}

	private List<Professor> consultaProfessor() {
		ProfessorBD professorBD = new ProfessorBD();
		List<Professor> professores = professorBD.consultaProfessores();
		return professores;

	}

	private List<Professor> consultaProfessor(String nome) {
		ProfessorBD professorBD = new ProfessorBD();
		List<Professor> professores = professorBD.consultaProfessor(nome);
		return professores;
	}

}
